﻿/* Copyright 2010 Igor Francé
 * 
 * This file is part of ECMADoc (http://ecmadoc.codeplex.com).
 * 
 * ECMADoc is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * ECMADoc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with ECMADoc. 
 * If not, see http://www.gnu.org/licenses/.
 */
namespace EcmaDoc.Core.Items
{
	using System;
	using System.Collections.Generic;
	using System.Linq;

	/// <summary>
	/// Implements a dictionary of <see cref="ItemProperty">item properties</see>
	/// </summary>
	public class PropertyCollection : Dictionary<string, List<ItemProperty>>
	{
		/// <summary>
		/// Determines whether this dictionary contains the specified <paramref name="property"/> under the 
		/// specified <paramref name="name"/>.
		/// </summary>
		/// <param name="name">The key under which to look.</param>
		/// <param name="property">The property to look for.</param>
		/// <returns>
		/// <c>true</c> if this dictionary contains the property equal to the specified <paramref name="property"/>; otherwise, 
		/// <c>false</c>.
		/// </returns>
		public bool Contains(string name, ItemProperty property)
		{
			if (!this.ContainsKey(name))
				return false;

			return this[name].Any(prop => prop.Equals(property));
		}
	}
}
